package com.kcyu.sfherp.mapper.ms;

import com.kcyu.sfherp.entity.Efficiency;
import com.kcyu.sfherp.entity.SumStatistic;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;

@Repository
public interface EfficiencyMapper {

    @Select("select count(id) as counter,sum(je) as totalje from chzd where rq < '${endTime}' and rq > '${startTime}' and je <> 0")
    public Efficiency analysisZD(@Param("startTime") String startTime,@Param("endTime") String endTime);

    @Select("select count(id) as counter,sum(je) as totalje from orchzd where rq < '${endTime}' and rq > '${startTime}' and je <> 0")
    public Efficiency analysisDD(@Param("startTime") String startTime,@Param("endTime") String endTime);

    @Select("select opman, count(id) as 'counter' from chzd where rq > '${startTime}' and rq < '${endTime}' group by opman order by count(id) desc")
    public List<Efficiency> getTodayOpmanZDEffi(@Param("startTime") String startTime,@Param("endTime") String endTime);

    @Select("select opman, count(id) as 'counter' from orchzd where rq > '${startTime}' and rq < '${endTime}' group by opman order by count(id) desc")
    public List<Efficiency> getTodayOpmanDDEffi(@Param("startTime") String startTime,@Param("endTime") String endTime);

    @Select("SELECT sum(je) as je,sum(ml) as ml,CONVERT ( VARCHAR ( 100 ), rq, 23 ) as rq FROM [dbo].[chzd] WHERE [rq] >= N'${startTime}' and [rq] <= N'${endTime} 23:59:59' group by CONVERT ( VARCHAR ( 100 ), rq, 23 ) order by rq")
    public List<SumStatistic> getSumStatisic(@Param("startTime") String startTime,@Param("endTime") String endTime);
}
